package thread;
/**
 * 获取线程信息的相关方法
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();//实例化主线程
        String name = main.getName();
        System.out.println("名字"+name);

        Thread t = Thread.currentThread();
        String tn = t.getName();
        System.out.println(tn);

        long id = main.getId();
        System.out.println("唯一标识"+id);

        int priority = main.getPriority();
        System.out.println("优先级："+priority);

        boolean isAlive = main.isAlive();
        System.out.println("是否活着："+isAlive);

        boolean isDeamon = main.isDaemon();
        System.out.println("是否为守护线程："+isDeamon);

        boolean isInterrupted = main.isInterrupted();
        System.out.println("是否被中断："+isInterrupted);

    }
}
